<?php

namespace app\api\controller\douyin;
use app\api\service\douyin\EventService;
use think\Request;

class Event
{
    protected $Service;
    public function __construct()
    {
        $this->Service = EventService::getInstance();
    }


    /**
     * 采集分享解析素材
     * @return \think\response\Json
     */
    public function store(Request $request){
        $params = $request->post();
        $result = $this->Service->store($params['data']);
        return writeJson(200,$result,'采集完成！');
    }


    /**
     * @auth('随机拉取抖音分享解析素材','抖音分享业务')
     * @param Request $request
     * @return \think\response\Json
     */
    public function randomStore(Request $request){
        $params = $request->get();
        $result = $this->Service->randomStore($params);
        return writeJson(200,$result,'数据！');
    }

    /**
     * @auth('创建抖音分享分发任务','抖音分享业务')
     * @param Request $request
     * @param('title','标题','require')
     * @param('imgs','图片','array')
     * @param('app_id','发布账户','require')
     * @return \think\response\Json
     */
    public function addEvent(Request $request){
        $params = $request->post();
        $result = $this->Service->addEvent($params);
        return writeJson(200,$result,'创建成功！');
    }


    /**
     * @auth('查询抖音分享分发任务','抖音分享业务')
     * @param Request $request
     * @param('page','页数','require')
     * @return \think\response\Json
     */
    public function getEvent(Request $request){
        $params = $request->get();
        $result = $this->Service->getEvent($params);
        return writeJson(200,$result,'数据列表！');
    }

    /**
     * @auth('抖音分享','抖音分享业务')
     * @param Request $request
     * @param('id','任务id','require')
     * @return \think\response\Json
     */
    public function share(Request $request){
        $params = $request->get();
        $result = $this->Service->share($params);
        return writeJson(200,$result,'分享！');
    }


    /**
     * @auth('回填抖音分享链接','抖音分享业务')
     * @param Request $request
     * @param('id','任务id','require')
     * @param('url','地址','require')
     * @return \think\response\Json
     */
    public function backfillUrl(Request $request){
        $params = $request->post();
        $result = $this->Service->backfillUrl($params);
        return writeJson(200,$result,'回填！');
    }

}
